home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / windoze / code.lua next >
Encoding:
Text File  |  2005-07-16  |  9.3 KB  |  258 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky13.ogg")
  8.     local pokus = getRestartCount()
  9.     local roompole = createArray(2)
  10.  
  11.  
  12.     -- -------------------------------------------------------------
  13.     local function prog_init_room()
  14.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  15.  
  16.         room.resit = 0
  17.         room.umrela = 0
  18.         room.navrhy = random(500) + 200
  19.         room.poslnavrh = 4
  20.         room.odire = 0
  21.         room.onotepadu = 0
  22.         room.ooknech = 0
  23.         room.obonusu = 0
  24.         room.obordelu = 0
  25.         room.ooceli = 0
  26.         room.hlasky = random(100) + 20
  27.         room.nhlasek = 0
  28.         local backup_stdBlackJokes = stdBlackJoke
  29.         local autoRestart = 0
  30.  
  31.         return function()
  32.             if room.resit == 1 then
  33.                 if staramala:isOut() and staravelka:isOut() then
  34.                     room.resit = 2
  35.                     big:setBusy(false)
  36.                     small:setBusy(false)
  37.                     --NOTE: turn on standard black jokes
  38.                     stdBlackJoke = backup_stdBlackJokes
  39.                 else
  40.                     game_setFastFalling(true)
  41.                     big:setBusy(true)
  42.                     small:setBusy(true)
  43.                 end
  44.             else
  45.                 game_setFastFalling(false)
  46.                 staramala:setBusy(true)
  47.                 staravelka:setBusy(true)
  48.             end
  49.             if autoRestart == 0 and (
  50.                 (not staramala:isAlive() and (not staravelka:isAlive() or staravelka:isOut())) or
  51.                 (not staravelka:isAlive() and (not staramala:isAlive() or staramala:isOut())) or
  52.                 (not small:isAlive() and not big:isAlive())) then
  53.                 autoRestart = 1
  54.                 level_planShow(function(count)
  55.                     if count == 60 then
  56.                         return level_action_restart()
  57.                     else
  58.                         return false
  59.                     end
  60.                 end)
  61.             end
  62.  
  63.             if room.resit == 0 then
  64.                 if big:getTouchDir() ~= dir_no and bonuslevel:getTouchDir() ~= dir_no then
  65.                     room.resit = 1
  66.                     roompole[1] = 1
  67.                     room.obonusu = 0
  68.                     big:setBusy(true)
  69.                     small:setBusy(true)
  70.                     staramala:setBusy(false)
  71.                     staravelka:setBusy(false)
  72.                     game_checkActive()
  73.                     if pokus == 1 then
  74.                         addv(0, "win-v-pockej")
  75.                         addm(2, "win-m-zavrene")
  76.                     end
  77.                     if pokus < 3 or random(100) < 40 then
  78.                         addv(5, "win-v-osvobodit")
  79.                         addm(10, "win-m-ven")
  80.                         addv(0, "win-v-citim")
  81.                         addm(random(10) + 5, "win-m-vzit")
  82.                     end
  83.                     addv(5, "win-v-nehrajem")
  84.                     --NOTE: turn off standard black jokes
  85.                     stdBlackJoke = function() end
  86.                 end
  87.             end
  88.             if room.resit == 1 then
  89.                 if room.umrela == 0 and isReady(staramala) and not staravelka:isAlive() then
  90.                     room.umrela = 1
  91.                     addm(5, "win-m-jejda")
  92.                 elseif room.umrela == 0 and isReady(staravelka) and not staramala:isAlive() then
  93.                     room.umrela = 1
  94.                     addv(5, "win-v-real")
  95.                 end
  96.             end
  97.             if room.resit ~= 1 and no_dialog() and isReady(small) and isReady(big) then
  98.                 if room.navrhy > 0 then
  99.                     room.navrhy = room.navrhy - 1
  100.                 end
  101.                 if room.hlasky > 0 then
  102.                     room.hlasky = room.hlasky - 1
  103.                 end
  104.                 if room.navrhy == 0 then
  105.                     room.navrhy = random(1500) + 200
  106.                     pom1 = random(4)
  107.                     if room.poslnavrh == pom1 then
  108.                         pom1 = 4
  109.                     end
  110.                     addm(30, "win-m-costim"..pom1)
  111.                     adddel(30)
  112.                 elseif room.ooceli == 0 and dist(small, bonuslevel) <= 1 then
  113.                     room.ooceli = 1
  114.                     addm(5, "win-m-vga")
  115.                 elseif room.hlasky == 0 then
  116.                     pom1 = random(5)
  117.                     room.nhlasek = room.nhlasek + 1
  118.                     room.hlasky = random(300) + 300
  119.                     if roompole[0] == 0 and room.nhlasek == 2 then
  120.                         pom1 = 0
  121.                     end
  122.                     switch(pom1){
  123.                         [0] = function()
  124.                             if room.obonusu == 0 then
  125.                                 room.obonusu = 1
  126.                                 addm(10, "win-m-okno")
  127.                                 addv(8, "win-v-hra")
  128.                                 addm(random(10) + 10, "win-m-chodila")
  129.                                 addv(2, "win-v-nic0")
  130.                                 addm(2, "win-m-nic1")
  131.                                 addv(2, "win-v-nic2")
  132.                                 addm(5, "win-m-nic3")
  133.                                 addv(random(10) + 10, "win-v-hav")
  134.                                 if roompole[1] == 0 then
  135.                                     addm(random(30) + 10, "win-m-zahrat")
  136.                                 end
  137.                             end
  138.                         end,
  139.                         [1] = function()
  140.                             if room.onotepadu == 0 then
  141.                                 room.onotepadu = 1
  142.                                 addm(10, "win-m-blok")
  143.                                 adddel(random(15) + 5)
  144.                                 planSet(notepad, "napsano", 1)
  145.                                 adddel(random(15) + 5)
  146.                                 planSet(notepad, "napsano", 2)
  147.                                 adddel(random(15) + 5)
  148.                                 planSet(notepad, "napsano", 3)
  149.                                 adddel(random(15) + 5)
  150.                                 planSet(notepad, "napsano", 4)
  151.                                 addv(10, "win-v-premyslej")
  152.                             end
  153.                         end,
  154.                         [2] = function()
  155.                             if room.odire == 0 then
  156.                                 room.odire = 1
  157.                                 addm(30, "win-m-dira")
  158.                                 addv(3, "win-v-tamhle")
  159.                             end
  160.                         end,
  161.                         [3] = function()
  162.                             if room.ooknech == 0 then
  163.                                 room.ooknech = 1
  164.                                 addv(20, "win-v-pocitala")
  165.                                 addm(5, "win-m-nemusim")
  166.                             end
  167.                         end,
  168.                         [4] = function()
  169.                             if room.obordelu == 0 then
  170.                                 room.obordelu = 1
  171.                                 addv(30, "win-v-plocha")
  172.                             end
  173.                         end,
  174.                     }
  175.                 end
  176.             end
  177.         end
  178.     end
  179.  
  180.     -- -------------------------------------------------------------
  181.     local function prog_init_bonuslevel()
  182.         return function()
  183.             if room.resit == 1 then
  184.                 bonuslevel.afaze = 1
  185.             else
  186.                 bonuslevel.afaze = 0
  187.             end
  188.             bonuslevel:updateAnim()
  189.         end
  190.     end
  191.  
  192.     -- -------------------------------------------------------------
  193.     local function prog_init_notepad()
  194.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  195.  
  196.         notepad.napsano = 0
  197.  
  198.         return function()
  199.             notepad.afaze = notepad.napsano * 2 + math.floor(math.mod(game_getCycles(), 10) / 5)
  200.             notepad:updateAnim()
  201.         end
  202.     end
  203.  
  204.     -- -------------------------------------------------------------
  205.     local function prog_init_staravelka()
  206.     end
  207.  
  208.     -- -------------------------------------------------------------
  209.     local function prog_init_staramala()
  210.     end
  211.  
  212.     -- -------------------------------------------------------------
  213.     local function prog_init_spuntik()
  214.         spuntik:setEffect("invisible")
  215.     end
  216.  
  217.     -- --------------------
  218.     local update_table = {}
  219.     local subinit
  220.     subinit = prog_init_room()
  221.     if subinit then
  222.         table.insert(update_table, subinit)
  223.     end
  224.     subinit = prog_init_bonuslevel()
  225.     if subinit then
  226.         table.insert(update_table, subinit)
  227.     end
  228.     subinit = prog_init_notepad()
  229.     if subinit then
  230.         table.insert(update_table, subinit)
  231.     end
  232.     subinit = prog_init_staravelka()
  233.     if subinit then
  234.         table.insert(update_table, subinit)
  235.     end
  236.     subinit = prog_init_staramala()
  237.     if subinit then
  238.         table.insert(update_table, subinit)
  239.     end
  240.     subinit = prog_init_spuntik()
  241.     if subinit then
  242.         table.insert(update_table, subinit)
  243.     end
  244.     return update_table
  245. end
  246. local update_table = prog_init()
  247.  
  248.  
  249. -- -----------------------------------------------------------------
  250. -- Update
  251. -- -----------------------------------------------------------------
  252. function prog_update()
  253.     for key, subupdate in pairs(update_table) do
  254.         subupdate()
  255.     end
  256. end
  257.  
  258.